Reprinted from: http://blog.chinaunix.net/u3/99423/showart_2100968.html
I have made many mistakes in the scanf function, and I have also seen mistakes made by others. Remember to remind myself not to repeat the same mistakes. If it is useful to you,
Ladies and gentlemen, crossing, we are talking about the example of getting the current date and time, and this is the example of the library function in the C language: scanf. Gossip Hugh, words return to the positive. Let's talk C chestnuts
The first thing we recommend is to use the gets function less.
I encountered this problem is a C language novice more likely to encounter a problem. It's about get () and GetChar () two functions. As we all know, the gets () function is an input
Test instructions Watashi invented a kind of egg ache (Eggache) language you want to implement an array slicing function for this language function is to have an array initially empty each time you give you an interval [L, R) and some number you
First, the scanf family1, the scanf family's prototype int scanf (char const *format,...); int fscanf (FILE *stream,char const *format,...); int sscanf (char const *buffer,char const *format,...); Ellipses in each prototype represent a
Scanf, gets, getchar, cin, cin. get, cin. getline, getline summary, cin. getcin. getline
I. scanf
Scanf can be used to read numbers, characters, and strings;
Conclusion:(1) When scanf reads a single character (% c) from the buffer, if the first
Both the scanf () function and the Get () function are available for input strings, but are functionally different. If you want to enter the string "Hi Hello" from the keyboard, you should use the gets function.The get can receive spaces, and scanf
About the problem of using scanf to input characters
1. scanf can be used to enter one character:
Char;
Scanf ("% C ",& A); // stop it &
If you want to enter two characters
Char A, B;
Scanf ("% C", & );
Scanf ("% C", & B );
Printf ("% C, % C \ n",
Scanf is a rare but useful conversion character: [...] and [^...].
# Include
Int main ()
{
Char strings [100];
Scanf ("% [1234567890]", strings );
Printf ("% s", strings );
Return 0;
}
Run. Input 1234werew and the result is 1234.
It can be found
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.